package concurrent.push;

import utils.DateTimeUtils;

import java.util.Date;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * Author: JasonW
 * Date: 13-12-22
 */
public class ExecutorTest {
    public static void main(String[] args) throws InterruptedException {
        BlockingDeque<PushingTask> taskQueue = new LinkedBlockingDeque<PushingTask>();
        int threadCount = 4;
        int maxQueueSize = 500;
        QueueManager queueManager = new QueueManager();
        Executor executor = new Executor(taskQueue, threadCount, maxQueueSize, queueManager);
        System.out.println(String.format("now :%s", DateTimeUtils.formatDate(new Date(), DateTimeUtils.DATE_TIME_FORMAT)));
        for (int i = 0; i < 300; i++) {
            executor.execute(new Task());
        }
        Thread.sleep(10000);
        executor.updateThread(6);

        Thread.sleep(20000);
        executor.updateThread(2);

        Thread.sleep(30000);
        executor.updateThread(3);
    }
}
